import {createRouter, createWebHistory,} from "vue-router";

const router = createRouter({
        history: createWebHistory(),
        linkActiveClass: 'active',
        linkExactActiveClass: 'exactActive',
        routes: [{
                path: '/',
                redirect: '/login'
            },
            {
                path: '/login',
                component: () =>
                    import ('../components/login.vue'),
            },
            {
                path: '/homes',
                component: () =>
                    import ('../components/homes.vue'),
                children: [
                    {
                        path: 'index',
                        component: () =>
                            import ('../components/index/Index.vue')
                    },
                    {
                        path: 'users',
                        component: () =>
                            import ('../components/user/Users.vue')
                    },
                    {
                        path: 'ex',
                        component: () =>
                            import ('../components/ex/Ex.vue')
                    },
                    {
                        path: 'exList',
                        component: () =>
                            import ('../components/ex/ex_list.vue')
                    },
                    {
                        path: 'shen',
                        component: () =>
                            import ('../components/shen/shen.vue')
                    },
                    {
                        path: 'order',
                        component: () =>
                            import ('../components/order/order.vue')
                    },
                    {
                        path: 'goods',
                        component: () =>
                            import ('../components/goods/goods.vue')
                    },
                    {
                        path: 'data_detail',
                        component: () =>
                            import ('../components/index/data_detail.vue')
                    }
                ]
            },
        ]
    })
    //路由守卫
// router.beforeEach((to, from, next) => {
//     if (to.path == '/login') return next()
//     if (window.localStorage.getItem('token')) return next()
//     next('/login')
// })
export default router;